<template>
  <el-main>
    <div class="container">
      <Tag />
      <Banner />
      <AnimateSection></AnimateSection>
    </div>
  </el-main>
</template>

<script>
import Tag from "~/components/index/Tag.vue";
import Banner from "~/components/index/Banner.vue";
import AnimateSection from "~/components/index/AnimateSection.vue";

export default {
  components: {
    Tag,
    Banner,
    AnimateSection
  },
  async fetch({ $axios, store }) {
    let [
      result1,
      result2,
      recommend,
      update,
      hot,
      sort,
      jp
    ] = await Promise.all([
      $axios.get("/api/tag?sort=idxOrder"),
      $axios.get("/api/banner?sort=idxOrder"),
      $axios.get("/api/work/recommend?page=0&size=6"),
      $axios.get("/api/work/update?page=0&size=6"),
      $axios.get("/api/work/hot?page=0&size=6"),
      $axios.get("/api/work/sort?page=0&size=6&sort=score&sortType=desc"),
      $axios.get("/api/work/jp?page=0&size=6")
    ]);

    {
      let { status, data } = result1;
      store.commit("tag/list", data);
    }

    {
      let { status, data } = result2;
      store.commit("banner/list", data);
    }

    {
      let list = [
        {
          name: "主编推荐",
          src: "/recommend",
          queryWorks: recommend.data.list
        },
        { name: "精选完结", src: "/update", queryWorks: update.data.list },
        { name: "最热漫画", src: "/hot", queryWorks: hot.data.list },
        { name: "收藏最多", src: "/sort", queryWorks: sort.data.list },
        { name: "经典日漫", src: "/jp", queryWorks: jp.data.list }

         
      ];
      store.commit("section/list", list);
    }
  }
};
</script>

<style scoped>
</style>
